package com.ellison.demo.example;

import com.ellison.demo.common.entity.WorkDoc;
import lombok.extern.slf4j.Slf4j;

import java.util.Comparator;

/**
 * <p>TODO</p>
 *
 * @author Ellison_Pei
 * @date 2021/10/25 14:06
 * @since 1.0
 **/
@Slf4j
public class ComparatorTest {
    public static void main(String[] args) {
//        Comparator<WorkDoc> comparator = (p1, p2) -> p1.getWorkTime().compareTo(p2.getWorkTime());
        Comparator<WorkDoc> comparator = Comparator.comparing(WorkDoc::getWorkTime);
        WorkDoc p1 = new WorkDoc();
        p1.setId(1000L);
        WorkDoc p2 = new WorkDoc();
        p1.setId(10020L);
        comparator.compare(p1, p2);
        comparator.reversed().compare(p1, p2);

    }
}
